package org.teremail;

import javax.sql.DataSource;

import org.postgresql.ds.PGSimpleDataSource;
import org.teremail.schema.Dialect;
import org.teremail.schema.PGDialect;

public class PGDBConfig extends AbstractDBConfig {
    
    private String name;
    private String user;
    private String pass;
    private int port;
    private String host;

    public PGDBConfig(String name, String user, String pass, String host, int port) {
        this.name = name;
        this.user = user;
        this.pass = pass;
        this.host = host;
        this.port = port;
    }

    @Override
    protected DataSource loadDS() {
        PGSimpleDataSource ds = new PGSimpleDataSource();
        ds.setDatabaseName(name);
        ds.setUser(user);
        ds.setPassword(pass);
        ds.setServerName(host);
        ds.setPortNumber(port);
        return ds;
    }

    public Dialect getDialect() {
        return PGDialect.getInstance();
    }

}
